package cn.opopopo.design_pattern_learn.结构型.composite;

// 所有文件和文件夹的统一接口
abstract class FileSystemComponent {
    protected String name;

    public FileSystemComponent(String name) {
        this.name = name;
    }

    // 公共操作
    public abstract void showDetails();

    // 可选的容器操作（默认抛出异常，叶子节点不支持）
    public void add(FileSystemComponent component) {
        throw new UnsupportedOperationException("不支持添加操作");
    }

    public void remove(FileSystemComponent component) {
        throw new UnsupportedOperationException("不支持删除操作");
    }

    public java.util.List<FileSystemComponent> getChildren() {
        throw new UnsupportedOperationException("不支持获取子元素");
    }
}